
package org.dyndns.cooland.updater.db;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class MyBatisConnectionFactory {
	
	private static SqlSessionFactory	sqlSessionFactory;
	
	static{
		try{
			String resource = "SqlMapConfig.xml";
			Reader reader = Resources.getResourceAsReader(resource);
			if (sqlSessionFactory == null){
				sqlSessionFactory = new SqlSessionFactoryBuilder()
						.build(reader);
			}
		}
		catch (FileNotFoundException e){
			e.printStackTrace();
		}
		catch (IOException e){
			e.printStackTrace();
		}
	}
	
	public static SqlSessionFactory getSqlSessionFactory() {

		return sqlSessionFactory;
	}
}
